T=int(input())
for i in range(T):
n=int(input())
arr=list(map(int,input().split()))
l=[]
r=[]
for i in range(n):
if i%2==0:
l.append(arr[i])
else:
r.append(arr[i])
l.sort()
r.sort()
arr.sort()
z=[]
for i in range(n):
if i%2==0:
z.append(l.pop(0))
else:
z.append(r.pop(0))
if z==arr:
print("YES")
else:
print("NO")
#include <bits/stdc++.h>
using namespace std;
// clang-format off
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define int long long
#define ld long double
#define pb push_back
#define vi vector<long long>
#define vll vector<long long>
#define rep(i,a,b) for (ll i=a;i<b;i++)
#define repa(container) for(auto& x:container)
#define repn(i,a,b) for (ll i=a;i>=b;i--)
#define all(x) x.begin(), x.end()
#define mod 1000000007 // 10^9+7
#define epsilon 0.0000000000001
// debug templates
#define debug(x) cerr<< #x <<" : "<< x << endl;
#define debuga(A,N) cerr<< #A <<" : [ ";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p) cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v) cerr<< #v <<" : "<<"[ ";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v) cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m) cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m) cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
// clang-format on
const int xn = 2e5 + 10;
const int xm = -20 + 10;
const int sq = 320;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
const ld eps = 1e-15;
const int base = 257;
int cnt[100001][2];
void solve() {
int n;cin>>n;
memset(cnt,0,sizeof(cnt));
vi a(n);
rep(i,0,n) {
cin>>a[i];
cnt[a[i]][i%2]++;
}
sort(all(a));
rep(i,0,n) {
cnt[a[i]][i%2]--;
}
bool flag=true;
rep(i,0,n) {
if(cnt[a[i]][0]!=0||cnt[a[i]][1]!=0) {
flag=false;
break;
}
}
if(flag)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
int32_t main() {
IOS;
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}
938. Range Sum of BST | 147. Insertion Sort List |
310. Minimum Height Trees | 2110. Number of Smooth Descent Periods of a Stock |
2109. Adding Spaces to a String | 2108. Find First Palindromic String in the Array |
394. Decode String | 902. Numbers At Most N Given Digit Set |
221. Maximal Square | 1200. Minimum Absolute Difference |
1619B - Squares and Cubes | 1619A - Square String |
1629B - GCD Arrays | 1629A - Download More RAM |
1629C - Meximum Array | 1629D - Peculiar Movie Preferences |
1629E - Grid Xor | 1629F1 - Game on Sum (Easy Version) |
2148. Count Elements With Strictly Smaller and Greater Elements | 2149. Rearrange Array Elements by Sign |
2150. Find All Lonely Numbers in the Array | 2151. Maximum Good People Based on Statements |
2144. Minimum Cost of Buying Candies With Discount | Non empty subsets |
1630A - And Matching | 1630B - Range and Partition |
1630C - Paint the Middle | 1630D - Flipping Range |
1328A - Divisibility Problem | 339A - Helpful Maths |